package com.dds.system.service.app.impl;

import java.util.List;
import java.util.Map;

import com.dds.common.core.domain.model.LoginUser;
import com.dds.common.utils.DateUtils;
import com.dds.common.utils.ServletUtils;
import com.dds.system.domain.app.AppAdv;
import com.dds.system.mapper.app.AppAdvMapper;
import com.dds.system.service.app.IAppAdvService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;

/**
 * 广告Service业务层处理
 *
 * @author gaolianjie
 * @date 2021-04-09
 */
@Service
public class AppAdvServiceImpl implements IAppAdvService {
    @Autowired
    private AppAdvMapper appAdvMapper;

    /**
     * 查询广告
     *
     * @param advId 广告ID
     * @return 广告
     */
    @Override
    public AppAdv selectAppAdvById(Long advId) {
        return appAdvMapper.selectAppAdvById(advId);
    }

    /**
     * 查询广告列表
     *
     * @param appAdv 广告
     * @return 广告
     */
    @Override
    public List<Map<String, Object>> selectAppAdvList(AppAdv appAdv) {
        return appAdvMapper.selectAppAdvList(appAdv);
    }

    /**
     * 新增广告
     *
     * @param appAdv 广告
     * @return 结果
     */
    @Override
    public int insertAppAdv(AppAdv appAdv, Long userId) {
        appAdv.setCreateTime(DateUtils.getNowDate());
        appAdv.setCreateUser(userId);
        return appAdvMapper.insertAppAdv(appAdv);
    }

    /**
     * 修改广告
     *
     * @param appAdv 广告
     * @return 结果
     */
    @Override
    public int updateAppAdv(AppAdv appAdv, Long userId) {
        appAdv.setUpdateTime(DateUtils.getNowDate());
        appAdv.setUpdateUser(userId);
        return appAdvMapper.updateAppAdv(appAdv);
    }

    /**
     * 批量删除广告
     *
     * @param advIds 需要删除的广告ID
     * @return 结果
     */
    @Override
    public int deleteAppAdvByIds(Long[] advIds) {
        return appAdvMapper.deleteAppAdvByIds(advIds);
    }

    /**
     * 删除广告信息
     *
     * @param advId 广告ID
     * @return 结果
     */
    @Override
    public int deleteAppAdvById(Long advId) {
        return appAdvMapper.deleteAppAdvById(advId);
    }
}
